package com.example.sharesinfo.ui;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.example.sharesinfo.MainActivity;
import com.example.sharesinfo.R;
import com.example.sharesinfo.base.BaseUIActivity;
import com.example.sharesinfo.entity.Constants;
import com.example.sharesinfo.utils.LogUtils;
import com.example.sharesinfo.utils.SpUtils;

public class WelcomeActivity extends BaseUIActivity {
    //延迟进入主页
    private Handler mHandler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message message) {
            switch (message.what) {
                case 1000:
                    startMain();
                    break;
            }
            return false;
        }
    });

    private void startMain() {
        boolean isLogin = SpUtils.getInstance().getBoolean(Constants.SP_IS_LOGIN, false);
        LogUtils.i("是否登录" + isLogin);
        if (isLogin) {
            startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
            finish();
        } else {
            startActivity(new Intent(WelcomeActivity.this, LoginActivity.class));
            finish();
        }

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        mHandler.sendEmptyMessageDelayed(1000, 1500);
    }
}
